package com.hjm.project.ActStage.ActStage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ActStage.ActStage.domain.ActStage;
import com.hjm.project.ActStage.ActStage.service.IActStageService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 阶梯Controller
 * 
 * @author LOVE
 * @date 2020-11-29
 */
@Controller
@RequestMapping("/ActStage/ActStage")
public class ActStageController extends BaseController
{
    private String prefix = "ActStage/ActStage";

    @Autowired
    private IActStageService actStageService;

    @RequiresPermissions("ActStage:ActStage:view")
    @GetMapping()
    public String ActStage()
    {
        return prefix + "/ActStage";
    }

    /**
     * 查询阶梯列表
     */
    @RequiresPermissions("ActStage:ActStage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActStage actStage)
    {
        startPage();
        List<ActStage> list = actStageService.selectActStageList(actStage);
        return getDataTable(list);
    }

    /**
     * 导出阶梯列表
     */
    @RequiresPermissions("ActStage:ActStage:export")
    @Log(title = "阶梯", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActStage actStage)
    {
        List<ActStage> list = actStageService.selectActStageList(actStage);
        ExcelUtil<ActStage> util = new ExcelUtil<ActStage>(ActStage.class);
        return util.exportExcel(list, "ActStage");
    }

    /**
     * 新增阶梯
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存阶梯
     */
    @RequiresPermissions("ActStage:ActStage:add")
    @Log(title = "阶梯", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActStage actStage)
    {
        return toAjax(actStageService.insertActStage(actStage));
    }

    /**
     * 修改阶梯
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ActStage actStage = actStageService.selectActStageById(id);
        mmap.put("actStage", actStage);
        return prefix + "/edit";
    }

    /**
     * 修改保存阶梯
     */
    @RequiresPermissions("ActStage:ActStage:edit")
    @Log(title = "阶梯", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActStage actStage)
    {
        return toAjax(actStageService.updateActStage(actStage));
    }

    /**
     * 删除阶梯
     */
    @RequiresPermissions("ActStage:ActStage:remove")
    @Log(title = "阶梯", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actStageService.deleteActStageByIds(ids));
    }
}
